package com.ruoyi.backend.controller;

import com.ruoyi.backend.domain.MessageNotice;
import com.ruoyi.backend.service.IMessageNoticeService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 消息通知Controller
 * 
 * @author wjr
 * @date 2025-09-23
 */
@RestController
@RequestMapping("/backend/t_message_notice")
@Api(tags = "消息通知")
public class MessageNoticeController extends BaseController
{
    @Autowired
    private IMessageNoticeService messageNoticeService;

    /**
     * 查询消息通知列表
     */
    @PreAuthorize("@ss.hasPermi('backend:t_message_notice:list')")
    @GetMapping("/list")
    @ApiOperation("查询消息通知列表")
    public TableDataInfo list(MessageNotice messageNotice)
    {
        startPage();
        List<MessageNotice> list = messageNoticeService.selectMessageNoticeList(messageNotice);
        return getDataTable(list);
    }

    /**
     * 获取消息通知详细信息
     */
    @PreAuthorize("@ss.hasPermi('backend:t_message_notice:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取消息通知详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(messageNoticeService.selectMessageNoticeById(id));
    }

    /**
     * 新增消息通知
     */
    @PreAuthorize("@ss.hasPermi('backend:t_message_notice:add')")
    @Log(title = "消息通知", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增消息通知")
    public AjaxResult add(@RequestBody MessageNotice messageNotice)
    {
        return toAjax(messageNoticeService.insertMessageNotice(messageNotice));
    }

    /**
     * 修改消息通知
     */
    @PreAuthorize("@ss.hasPermi('backend:t_message_notice:edit')")
    @Log(title = "消息通知", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改消息通知")
    public AjaxResult edit(@RequestBody MessageNotice messageNotice)
    {
        return toAjax(messageNoticeService.updateMessageNotice(messageNotice));
    }

    /**
     * 删除消息通知
     */
    @PreAuthorize("@ss.hasPermi('backend:t_message_notice:remove')")
    @Log(title = "消息通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除消息通知")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(messageNoticeService.deleteMessageNoticeByIds(ids));
    }

    /**
     * 导出消息通知列表
     */
    /*@PreAuthorize("@ss.hasPermi('backend:t_message_notice:export')")
    @Log(title = "消息通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MessageNotice messageNotice)
    {
        List<MessageNotice> list = messageNoticeService.selectMessageNoticeList(messageNotice);
        ExcelUtil<MessageNotice> util = new ExcelUtil<MessageNotice>(MessageNotice.class);
        util.exportExcel(response, list, "消息通知数据");
    }*/

}
